
import dao.CategoryDAO;
import dao.ProductDAO;
import dao.mysql.CategoryDAOImpl;
import dao.mysql.ProductDAOImpl;
import model.Category;
import model.Product;
import utility.DBConnection;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author Student
 */
public class Tester {

    public static void main(String args[]) {
      
        
        try {
            DBConnection db1 = new DBConnection();
//            CategoryDAO dao = new CategoryDAOImpl(db1.getConnection());
//            Category cat = dao.getCategoryById(4);
//            Product product = new Product();
//            product.setName("Supermie");
//            product.setDescription("-");
//            product.setPrice(2000);
//            product.setCategory(cat);
            ProductDAO pDao = new ProductDAOImpl(db1.getConnection());
//            pDao.save(product);
            Product p = pDao.getProductById(1);
            System.out.println(p.getName());
            System.out.println(p.getCategory().getName());
            
            p.setName("Indomie");
            
            pDao.update(p);
            
            System.out.println(p.getName());
            System.out.println(p.getCategory().getName());

            System.out.println("OK");
        } catch (Exception ex) {
        }
    }
}
